<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>收入-修改</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script type="text/javascript" src="./js/ie/html5.min.js"></script>
    <script type="text/javascript" src="./js/ie/respond.min.js"></script>
    <![endif]--></head>
<body>

<form class="layui-form" action="" lay-filter="example">
    <input type="hidden" id="id" name="id" value="1" th:value="${incomedetails.id}">
    <div class="layui-form-item">
        <label for="userId" class="layui-form-label">
            <span class="x-red">*</span>所属用户
        </label>
        <div class="layui-input-inline">
            <select name="userId" id="userId">
                <option value="1">张峰浦</option>
                <option value="2">杨小珍</option>
                <option value="3">张建强</option>
            </select>
        </div>
    </div>

    <input type="hidden" id="valid" name="valid" value="1" th:value="${incomedetails.valid}">

    <div class="layui-form-item">
        <label for="amountOfMoney" class="layui-form-label">
            <span class="x-red">*</span>理论收入
        </label>
        <div class="layui-input-inline">
            <input th:value="${incomedetails.amountOfMoney}" type="text" id="amountOfMoney" name="amountOfMoney" required="" lay-verify="required"
                   autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label for="amountOfMoneyActual" class="layui-form-label">
            <span class="x-red">*</span>税后收入</label>
        <div class="layui-input-inline">
            <input th:value="${incomedetails.amountOfMoneyActual}" type="text" id="amountOfMoneyActual" name="amountOfMoneyActual" required="" lay-verify="required"
                   autocomplete="off" class="layui-input"></div>
    </div>

    <div class="layui-form-item">
        <label for="largeClass" class="layui-form-label">
            <span class="x-red">*</span>收入来源
        </label>
        <div class="layui-input-inline">
            <select name="largeClass" id="largeClass">
                <option value="公司">公司</option>
                <option value="家庭">家庭</option>
                <option value="个人">个人</option>
                <option value="其它">其它</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label for="subClass" class="layui-form-label">
            <span class="x-red">*</span>收入原因</label>
        <div class="layui-input-inline">
            <input th:value="${incomedetails.subClass}" type="text" id="subClass" name="subClass" required="" lay-verify="required" autocomplete="off"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label for="note" class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <textarea th:text="${incomedetails.note}" placeholder="请输入内容" id="note" name="note" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label for="timeTransaction" class="layui-form-label">
            <span class="x-red">*</span>支出时间</label>
        <div class="layui-input-inline">
            <input th:value="${incomedetails.timeTransaction.toLocaleString()}" type="text" id="timeTransaction" name="timeTransaction" placeholder="yyyy-MM-dd HH:mm:ss" required=""
                   lay-verify="required"
                   autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        //日期
        laydate.render({
            elem: '#timeTransaction',
            type: 'datetime'
        });
        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');
        //监听提交
        form.on('submit(demo1)', function (data) {
            var id = document.getElementById("id").value;
            var userId = document.getElementById("userId").value;
            var valid = document.getElementById("valid").value;
            var amountOfMoneyActual = document.getElementById("amountOfMoneyActual").value;
            var amountOfMoney = document.getElementById("amountOfMoney").value;
            var largeClass = document.getElementById("largeClass").value;
            var subClass = document.getElementById("subClass").value;
            var note = document.getElementById("note").value;
            var timeTransaction = document.getElementById("timeTransaction").value;

            $.ajax({
                type: "post",
                url: "/updataIncomedetails",
                data: {
                    id: id,
                    userId: userId,
                    valid: valid,
                    amountOfMoneyActual: amountOfMoneyActual,
                    amountOfMoney: amountOfMoney,
                    largeClass: largeClass,
                    subClass: subClass,
                    note: note,
                    timeTransaction: timeTransaction
                },
                dataType: 'json',
                success: function (data) {

                },
                error: function (data) {
                    console.log("error");
                    console.log(data)
                }
            });
            layer.alert(JSON.stringify(data.field), {
                    title: '最终的提交信息'
                },
                function () {


                    var index = parent.layer.getFrameIndex(window.name);

                    parent.layer.close(index);
                });

            return false;
        });
    });
</script>

</body>


</html>